package com.gupaoedu.vip;

import com.gupaoedu.vip.discovery.IServiceDiscovery;
import com.gupaoedu.vip.discovery.ServiceDiscoveryWithZk;
import org.springframework.stereotype.Component;

import java.lang.reflect.Proxy;

/**
 * @Author: JLL
 * @Date: 2019/6/17 22:23
 */
public class RpcProxyClient {

    private IServiceDiscovery serviceDiscovery=new ServiceDiscoveryWithZk();

    public <T> T clientProxy(final Class<T> interfaceCls,  String version){
        return (T)Proxy.newProxyInstance(
                interfaceCls.getClassLoader(),
                new Class<?>[]{interfaceCls},
                new RemoteInvocationHandler(serviceDiscovery,version ));
    }


}
